package com.yun.demo.controller;

import com.yun.demo.mapper.UserMapper;
import com.yun.demo.service.DemoService;
import com.yun.domain.entity.User;
import com.yun.domain.query.UserQuery;
import com.yun.util.RestResult;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/demo")
public class DemoController {

    @Resource
    UserMapper userMapper;

    @Resource
    DemoService demoService;
    @PostMapping("/selectUser")
    public RestResult<List<User>> selectUser(UserQuery query){
        List<User> users = userMapper.selectUser(query);
        return RestResult.success(users);
    }

    @PostMapping("/insertUser")
    public RestResult<Object> insertUser(User user){
        int result = userMapper.insertUser(user);
        return RestResult.success(result);
    }

    @GetMapping("/serviceTest")
    public RestResult<Integer> serviceTest(){
        return demoService.serviceTest();
    }

}
